<?php
declare (strict_types = 1);

namespace app\api\model\v1;

use think\Model;

/**
 * @mixin \think\Model
 */
class Collect extends AppModel
{
    //"is_rectify" => "否"
    //  "case_grade" => "常规"
    const IS_RECTIFY_ONE = 1;
    const IS_RECTIFY_TWO = 2;


    const IS_CASE_GRADE_ONE = 1;
    const IS_CASE_GRADE_TWO = 2;


    const IS_STATUS_ZERO = 0;
    const IS_STATUS_ONE = 1;
    const IS_STATUS_TWO = 2;
    const IS_STATUS_THREE =3;

    //是否整改案件
    public static $is_rectify = array(
        self::IS_RECTIFY_ONE => '是',
        self::IS_RECTIFY_TWO => '否'
    );

    //案件等级
    public static $case_grade = array(
        self::IS_CASE_GRADE_ONE => '常规',
        self::IS_CASE_GRADE_TWO => '紧急'
    );

    //案件当前状态
    public static $is_status = array(
        self::IS_STATUS_ZERO => '全部',
        self::IS_STATUS_ONE => '待审核',
        self::IS_STATUS_TWO => '有效案件',
        self::IS_STATUS_THREE => '无效案件'
    );


    public function sample(){
        return $this->belongsTo(ProjectSample::class,'sample_id')->field('id,sample_title');
    }

    public function project(){
        return $this->belongsTo(Project::class,'project_id')->field('id,project_title');
    }

    public function target(){
        return $this->belongsTo(ProjectTarget::class,'target_id')->field('id,target_title,time_limit');
    }

    public function community(){
        return $this->belongsTo(Community::class,'community_id')->field('id,community_title');
    }

    public function admin(){
        return $this->belongsTo(Admins::class,'uid')->field('id,username');
    }

    public function unit(){
        return $this->belongsTo(GatherCompany::class,'gather_company_id')->field('id,gather_company_title');
    }

    public function zg(){
        return $this->hasMany(Rectification::class,'collect_id')->field('id,collect_id,type');;
    }
}
